package com.inspur.demo.service.impl;

import com.inspur.demo.dao.IUser2Dao;
import com.inspur.demo.dao.IUserDao;
import com.inspur.demo.model.User;
import com.inspur.demo.model.User2;
import com.inspur.demo.service.IUser2Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Optional;

/**
 * @ClassName IUserServiceImpl
 * @Description TODO
 * @Company inspur
 * @Author Mark.Zhang
 * @Date 2019/5/16 10:14
 * @Version 1.0 
 */
@Service
public class IUser2ServiceImpl implements IUser2Service {

    @Autowired
    IUser2Dao user2Dao;

    @Override
    public User2 create(User2 user) {
        System.out.println("service:" + user.toString());
        return user2Dao.save(user);
    }

    @Override
    public User2 find(String id) {
        Optional<User2> user = user2Dao.findById(id);
        if (user.isPresent()) {
            return user.get();
        } else {
            return null;
        }
    }
}
